/************************************************************************************
* Types.h                                                                           *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef TYPES_H
#define TYPES_H

#include <QHash>
#include <QList>

#define ALL_ARTISTS "All"
#define ALL_ALBUMS "All"
#define NOT_AVAILABLE "N/A"




class CollectorItem;

const int    FC_None     = 0x00;
const int    FC_All      = 0x0F;
const int    FC_Title    = 0x01;
const int    FC_Artist   = 0x02;
const int    FC_Album    = 0x04;

enum FilterRule {
    AndRule,
    OrRule
};

class ArtistInfo;

struct AlbumInfo {
    QList<CollectorItem *>* m_tracks;
    float m_avgRating;
    int m_numPlays;
    ArtistInfo *m_artist;
    QString m_albumName;

    explicit AlbumInfo(QString albumName, ArtistInfo *artist):m_albumName(albumName){
        m_artist = artist;
        m_tracks = new QList<CollectorItem *>;
        m_numPlays = 0;
        m_avgRating = 0.0;
    }

    ~AlbumInfo() {
        delete m_tracks;
    }
};

struct ArtistInfo {
    QHash<QString, AlbumInfo*> *m_albums;
    QString m_artistName;

    explicit ArtistInfo(QString artistName):m_artistName(artistName){
        m_albums = new QHash<QString, AlbumInfo *>;
    }

    ~ArtistInfo() {
        /* If we remove albums for all artists all other ArtistInfo's destructors
          will fail since they try to clear memory that is already cleared. */
        if(m_artistName != ALL_ARTISTS) {
            for(QHash<QString, AlbumInfo *>::iterator it = m_albums->begin();
                it != m_albums->end();
                ++ it) {
                delete it.value();
            }
        }
        delete m_albums;
    }
};


#endif // TYPES_H
